home *** CD-ROM | disk | FTP | other *** search
/ Hyper Stacks 1994 May / Hyper Stacks (Pacific HiTech)(1994)[Mac].iso / HyperTalk / Groupies 3.2 / stack.txt < prev   
Encoding:
Text File  |  1988-12-20  |  14.6 KB  |  459 lines

  1. -- stack: in.2
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 2
  11. -- first background id: 5072
  12. -- card count: 7
  13. -- first card id: 5256
  14. -- list block id: 4741
  15. -- print block id: 2457
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 50144 bytes
  21. -- stack block size: 13824 bytes
  22. -- created by hypercard version: 0x01208000
  23. -- compacted by hypercard version: 0x01228000
  24. -- modified by hypercard version: 0x01228000
  25. -- opened by hypercard version: 0x01228000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. ---------------------------------------------------------------------
  69. -- Groupies 3.0, a utility for grouping objects, by Sioux Lacy
  70. -- This stack is public domain.  Happy grouping!
  71. --
  72. -- 04 May 1988  v2.1  revised for HyperCard version 1.2
  73. -- 07 May 1988  v2.2  added ability to copy the text in fields
  74. -- 01 June 1988 v2.3  revised to allow selection by dragging a rect
  75. -- 02 June 1988 v2.4  revised for use with functionKeys f5 thru f10
  76. -- 22 July 1988 v3.0  added equal space feature, revised presentation
  77. --
  78. -- Many thanks to Bill Atkinson for his help and encouragement
  79. ---------------------------------------------------------------------
  80.  
  81. -- You don't need to copy this first handler to your Home stack
  82. -- unless you have an extended keyboard (with function keys).
  83.  
  84. -- On an extended keyboard, this handler can be used to do Groupies
  85. -- messages by typing the function keys.  It uses keys F5 thru F11.
  86.  
  87. on functionKey whichKey
  88.   global objectList
  89.   if whichKey < 5 or whichKey > 11 then pass functionKey
  90.   if whichKey is 5 then Group
  91.   else if whichKey is 6 then Move
  92.   else if whichKey is 7 then Copy
  93.   else if whichKey is 8 then Paste
  94.   else if whichKey is 9 then Erase
  95.   else if whichKey is 10 then Align
  96.   else if whichKey is 11 then Adjust
  97. end functionKey
  98.  
  99. ---------------------------------------------------------------------
  100. -- GROUPIES HANDLERS START HERE
  101. ---------------------------------------------------------------------
  102.  
  103. -- Message: Group
  104. -- This will let the user designate a number of objects to be grouped
  105. -- either by clicking on them, or showing a surrounding rectangle
  106.  
  107. on Group
  108.   global objectList, whereTheGroupIs
  109.   put "Objects" into selectMethod  -- default method
  110.   if the optionKey is down then
  111.     put Choice("Group objects by selecting:", "Objects", "Area") into selectMethod
  112.   end if
  113.   if selectMethod is "Objects" then
  114.     Confirm "Click buttons or fields, then press command."
  115.     put empty into objectList
  116.     put empty into whereTheGroupIs
  117.     repeat until the commandKey is down
  118.       set cursor to arrow
  119.       if the mouseClick then
  120.         set cursor to watch
  121.         put HitTest(the clickLoc) into hitWhat
  122.         if hitWhat is not empty and hitWhat is not in objectList
  123.         then put hitWhat & "," after objectList
  124.       else beep  -- invalid hit or nothing hit
  125.     end if
  126.   end repeat
  127. else   -- selectMethod is "Area"
  128.   Confirm "Use 2 clicks to show opposite corners of area."
  129.   put empty into objectList
  130.   put empty into whereTheGroupIs
  131.   set cursor to cross
  132.   wait until the mouseClick
  133.   put the clickLoc into selectRect
  134.   DrawMarker selectRect
  135.   wait until the mouseClick
  136.   put "," & the clickLoc after selectRect
  137.   DrawMarker the clickLoc
  138.   set cursor to watch
  139.   EraseMarkers
  140.   WithinRect selectRect
  141. end if
  142. delete last char of objectList   -- get rid of trailing comma
  143. choose browse tool
  144. end Group
  145.  
  146. -- Message: Move
  147. -- This will reposition (on the current card) all the
  148. -- grouped objects.
  149. -- They will follow the mouse location.
  150.  
  151. on Move
  152.   global objectList
  153.   CheckGroup
  154.   Confirm "Click and drag the group with mouse down."
  155.   set cursor to arrow
  156.   wait until the mouse is down
  157.   put the mouseLoc into thisLoc
  158.   repeat while the mouse is down
  159.     put thisLoc into lastLoc
  160.     put the mouseLoc into thisLoc
  161.     if thisLoc is not lastLoc then
  162.       put item 1 of thisLoc - item 1 of lastLoc into deltaX
  163.       put item 2 of thisLoc - item 2 of lastLoc into deltaY
  164.       lock screen
  165.       repeat with i = 1 to the number of items in objectList
  166.         put item i of objectList into object
  167.         get location of object
  168.         add deltaX to item 1 of it
  169.         add deltaY to item 2 of it
  170.         set location of object to it
  171.       end repeat
  172.       unlock screen
  173.     end if
  174.   end repeat
  175. end Move
  176.  
  177. -- Message: Copy
  178. -- This will remember, in a global variable, the current card.  Then,
  179. -- when the user 'pastes', the objects will be copied from that card.
  180.  
  181. on Copy
  182.   global whereTheGroupIs, savedUserLevel
  183.   CheckGroup
  184.   put the userLevel into savedUserLevel
  185.   set the userLevel to 5   -- will be restored after 'Paste'
  186.   Confirm "Go wherever you wish and 'Paste'."
  187.   put the long id of this card into WhereTheGroupIs
  188. end Copy
  189.  
  190. -- Message: Paste
  191. -- This will paste all the objects in the group into the current card /
  192. -- background. It must be preceded by 'Copy'.
  193.  
  194. on Paste
  195.   global objectList, WhereTheGroupIs, savedUserLevel
  196.   CheckGroup
  197.   if WhereTheGroupIs is empty
  198.   then Abort "Please choose 'Copy' before 'Paste'."
  199.   set cursor to watch
  200.   set lockMessages to true
  201.   lock screen
  202.   repeat with i = 1 to the number of items in objectList
  203.     push this card
  204.     go to WhereTheGroupIs
  205.     put item i of objectList into object
  206.     if word 2 of object is "field"
  207.     then put the value of object into copyOfText
  208.     select object
  209.     type "C" with commandKey
  210.     pop card
  211.     set editBkgnd to (word 1 of object = "bkgnd")
  212.     type "V" with commandKey
  213.     if word 2 of object is "field" then
  214.       if word 1 of object is "bkgnd"
  215.       then put copyOfText into bkgnd field (the number of bkgnd fields)
  216.     else put copyOfText into card field (the number of card fields)
  217.   end if
  218. end repeat
  219. choose browse tool
  220. unlock screen
  221. set the userLevel to savedUserLevel
  222. Prompt "These new objects are not grouped. The old group is still valid."
  223. end Paste
  224.  
  225. -- Message: Erase
  226. -- This will delete all the objects in the group. They are removed
  227. -- from the stack, and the operation is not undoable.
  228.  
  229. on Erase
  230.   global objectList, WhereTheGroupIs
  231.   CheckGroup
  232.   Confirm "Deleting group is not undoable. Are you sure?"
  233.   repeat with i = the number of items in objectList down to 1
  234.     select item i of objectList
  235.     type "X" with commandKey
  236.   end repeat
  237.   put empty into objectList
  238.   put empty into WhereTheGroupIs
  239.   choose browse tool
  240. end Erase
  241.  
  242. -- Message: Align
  243. -- This will line up the objects flush left, right, top or bottom,
  244. -- depending on the user's wishes.
  245.  
  246. on Align
  247.   global objectList
  248.   CheckGroup
  249.   put Choice("Adjust members by moving them:","Left/Right","Up/Down") into axis
  250.   if axis is "Up/Down"
  251.   then answer "Align objects at:" with "Top" or "Bottom" or "Center"
  252. else answer "Align objects at:" with "Left" or "Right" or "Center"
  253. put it into alignment
  254. Confirm "Click where you wish them to align."
  255. set cursor to cross
  256. wait until the mouseClick
  257. if alignment is "Center" then
  258.   repeat with i = 1 to the number of items in objectList
  259.     put item i of objectList into object
  260.     get location of object
  261.     if axis is "Up/Down"
  262.     then put the clickV into item 2 of it
  263.   else put the clickH into item 1 of it
  264.   set location of object to it
  265. end repeat
  266. else
  267.   repeat with i = 1 to the number of items in objectList
  268.     put item i of objectList into object
  269.     if axis is "Up/Down" then
  270.       if alignment is "Top"
  271.       then set top of object to the clickV
  272.     else set bottom of object to the clickV
  273.   else if axis is "Left/Right" then
  274.     if alignment is "Left"
  275.     then set left of object to the clickH
  276.   else set right of object to the clickH
  277. end if
  278. end repeat
  279. end if
  280. end Align
  281.  
  282. -- Message: Adjust
  283. -- This will put an equal amount of 'white' space between consecutive
  284. -- objects in the group. Note that the objects must be in ascending
  285. -- order for this to work as expected.
  286.  
  287. on Adjust
  288.   global objectList
  289.   CheckGroup
  290.   put Choice("Adjust space between objects:","Horizontally","Vertically") into adjust
  291.   Confirm "Use 2 clicks to show desired spacing."
  292.   set cursor to cross
  293.   wait until the mouseClick
  294.   put the clickLoc into startLoc
  295.   DrawMarker startLoc
  296.   wait until the mouseClick
  297.   put the clickLoc into endLoc
  298.   DrawMarker endLoc
  299.   SortGroup adjust
  300.   if adjust = "Horizontally" then
  301.     put abs(item 1 of endLoc - item 1 of startLoc) into horizSpace
  302.     put right of item 1 of objectList into lastRight
  303.     repeat with i = 2 to the number of items in objectList
  304.       put item i of objectList into object
  305.       set left of object to lastRight + horizSpace
  306.       put right of object into lastRight
  307.     end repeat
  308.   else  -- adjust "Vertically"
  309.     put abs(item 2 of endLoc - item 2 of startLoc) into vertSpace
  310.     put bottom of item 1 of objectList into lastBottom
  311.     repeat with i = 2 to the number of items in objectList
  312.       put item i of objectList into object
  313.       set top of object to lastBottom + vertSpace
  314.       put bottom of object into lastBottom
  315.     end repeat
  316.   end if
  317.   EraseMarkers
  318. end Adjust
  319.  
  320. -------------------------------------------------------------
  321.  
  322. on Abort what
  323.   answer what
  324.   exit to HyperCard
  325. end Abort
  326.  
  327. on CheckGroup
  328.   global objectList
  329.   if objectList is empty then Abort "There are no objects in the group."
  330. end CheckGroup
  331.  
  332. function Choice prompt, choice1, choice2
  333. answer prompt with choice1 or choice2 or "Cancel"
  334. if it is "Cancel" then exit to HyperCard
  335. return it
  336. end Choice
  337.  
  338. on Confirm what
  339.   answer what with "Cancel" or "OK"
  340.   if it is "Cancel" then exit to HyperCard
  341. end Confirm
  342.  
  343. on DrawMarker where
  344.   lock screen
  345.   doMenu "New Button"
  346.   put the number of card btns into newBtn
  347.   set icon of card btn newBtn to "Marker Cross"
  348.   set style of card btn newBtn to transparent
  349.   set showName of card btn newBtn to false
  350.   set rect of card btn newBtn to 0,0,20,20
  351.   set loc of card btn newBtn to where
  352.   set name of card btn newBtn to empty
  353.   choose browse tool
  354.   unlock screen
  355. end DrawMarker
  356.  
  357. on EraseMarkers
  358.   lock screen
  359.   select card btn (the number of card btns)
  360.   doMenu "Clear Button"
  361.   select card btn (the number of card btns)
  362.   doMenu "Clear Button"
  363.   choose browse tool
  364.   unlock screen
  365. end EraseMarkers
  366.  
  367. function HitTest where
  368. repeat with i = the number of card buttons down to 1
  369.   if where is within rect of card button i then
  370.     if visible of card button i
  371.     then return "card button id " & the id of card button i
  372.   end if
  373. end repeat
  374. repeat with i = the number of card fields down to 1
  375.   if where is within rect of card field i then
  376.     if visible of card field i
  377.     then return "card field id " & the id of card field i
  378.   end if
  379. end repeat
  380. repeat with i = the number of bkgnd buttons down to 1
  381.   if where is within rect of bkgnd button i then
  382.     if visible of bkgnd button i
  383.     then return "bkgnd button id " & the id of bkgnd button i
  384.   end if
  385. end repeat
  386. repeat with i = the number of bkgnd fields down to 1
  387.   if where is within rect of bkgnd field i then
  388.     if visible of bkgnd field i
  389.     then return "bkgnd field id " & the id of bkgnd field i
  390.   end if
  391. end repeat
  392. return empty
  393. end HitTest
  394.  
  395. on Prompt what
  396.   put what
  397.   put the seconds into startTime
  398.   put the mouseLoc into startLoc
  399.   wait until (the seconds = startTime+10) or (the mouseLoc <>¬¨ startLoc)
  400.   put empty into message box
  401.   hide message box
  402. end Prompt
  403.  
  404. on SortGroup how
  405.   global objectList
  406.   put empty into sortedList
  407.   if how is "Vertically" then put true into verticalSort
  408.   else put false into verticalSort
  409.   repeat with i = 1 to the number of items in objectList
  410.     put false into inserted
  411.     if verticalSort then get top of item i of objectList
  412.     else get left of item i of objectList
  413.     repeat with j = 1 to the number of items in sortedList
  414.       if (verticalSort and (it < top of item j of sortedList)) or (not verticalSort and (it < left of item j of sortedList)) then
  415.         put item i of objectList & "," before item j of sortedList
  416.         put true into inserted
  417.         exit repeat
  418.       end if
  419.     end repeat
  420.     if inserted is false then put item i of objectList & "," after sortedList
  421.   end repeat
  422.   delete last char of sortedList
  423.   put sortedList into objectList
  424. end SortGroup
  425.  
  426. on WithinRect selectRect
  427.   global objectList
  428.   repeat with i = the number of card buttons down to 1
  429.     if the loc of card button i is within selectRect then
  430.       if visible of card button i
  431.       then put "card button id " & the id of card button i & "," after objectList
  432.     end if
  433.   end repeat
  434.   repeat with i = the number of card fields down to 1
  435.     if the loc of card field i is within selectRect then
  436.       if visible of card field i
  437.       then put "card field id " & the id of card field i & "," after objectList
  438.     end if
  439.   end repeat
  440.   repeat with i = the number of bkgnd buttons down to 1
  441.     if the loc of bkgnd button i is within selectRect then
  442.       if visible of bkgnd button i
  443.       then put "bkgnd button id " & the id of bkgnd button i & "," after objectList
  444.     end if
  445.   end repeat
  446.   repeat with i = the number of bkgnd fields down to 1
  447.     if the loc of bkgnd field i is within selectRect then
  448.       if visible of bkgnd field i
  449.       then put "bkgnd field id " & the id of bkgnd field i & "," after objectList
  450.     end if
  451.   end repeat
  452. end WithinRect
  453.  
  454. ---------------------------------------------------------------------
  455. -- GROUPIES HANDLERS END HERE
  456. ---------------------------------------------------------------------
  457.  
  458.  
  459.